package filters;

import java.io.IOException;

import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.filter.OncePerRequestFilter;

import util.GmailUtilities;

public class RuntimeFilter extends OncePerRequestFilter {
	
	@Autowired
	GmailUtilities gutil;
	
	@Override
	protected void doFilterInternal(HttpServletRequest request,
			HttpServletResponse response, FilterChain filterChain)
			throws ServletException, IOException {

		try {
			filterChain.doFilter(request, response);
		} catch (Exception e) {
			try {
				e.printStackTrace();
				//gutil.connectSend(e.getMessage());
			} catch (Exception e1) {
				((HttpServletResponse) response).sendRedirect("../general/error");
			}
			((HttpServletResponse) response).sendRedirect("../general/error");
		}
	}
		
	public void destroy() {
		// TODO Auto-generated method stub
	}
}
